<?php
class ChangePasswordForm extends Form
{
	function ChangePasswordForm(){
		Form::Form('ChangePassword');
		$this->link_css('style/personal.css');
		$this->link_js('javascript/jquery/packed/jquery.validate.js');
		$this->link_js('javascript/personal.js');		
		$this->link_js('javascript/jquery/packed/jquery.jeditable.js');			
		CGlobal::$website_title = "Thay đổi mật khẩu";
	}
	
	
	function draw(){
		global $display;				
		
		if (User::id()!=0){																		
			if(User::$current->data["avatar_url"]!=""){
				$avatar =  '<img src="'.AZLib::getImageThumb(User::$current->data["avatar_url"],100,100,0,User::$current->data["img_server"]).'" />';
			}
			else{
				$avatar = '<img src="style/images/no_avatar_item.gif" width="94" height="94"/>';
			}
			$display->add('avatar',$avatar);
			
			$display->add('user_name',User::$current->data["user_name"]);					
			$display->add('get_cmd',Url::get('cmd'));					
			$display->add('get_action',Url::get('action'));
			$display->add('get_page',Url::get('page'));	
			
	  	    $display->add('get_page',  AZNet::$page['name']);
			$display->add('get_cmd',   Url::get('cmd'));
			$display->add('user_name', User::user_name());
			$display->add('can_edit_blast',((User::is_admin()) || !User::is_block()));
			$blast			= User::$current->data['blast'];
			$avatar_link 	= '';
			$avatar_url 	= 'style/images/no_avatar_item.gif';
				
			if(User::$current->data['avatar_url'] != ''){
				$avatar_link 	= "http://".CGlobal::$img_server[User::$current->data['img_server']].User::$current->data['avatar_url'];
				$avatar_url 	= AZLib::getImageThumb(User::$current->data['avatar_url'],80,80,0,User::$current->data['img_server']);
			}
			
			if($blast == ''){
				$blast = '...';
			}
			else{
				$blast = ' '.$blast;
				if(strpos($blast,'http://')){
					$user_blast = $blast;
					while(strpos($user_blast,'http://')){
						$tmp = substr($user_blast,strpos($user_blast,'http://'));
						
						if(strpos($tmp,' ') || strpos($tmp,'<')){
							if(strpos($tmp,' ') && strpos($tmp,'<') && (strpos($tmp,' ') > strpos($tmp,'<'))){
								$blast_url = substr($tmp,0,strpos($tmp,'<'));
							}
							else{
								$blast_url = substr($tmp,0,strpos($tmp,' '));
							}
						}
						else{
							$blast_url = $tmp;
						}
						$user_blast = str_replace($blast_url,'',$user_blast);
					}
					$new_blast_url = ' <a rel="nofollow" href="'.$blast_url.'" target="_blank">Click here</a>';
					$blast = substr($user_blast.$new_blast_url,1);
				}
			}
			
			$display->add('avatar_link',$avatar_link);
			$display->add('avatar_url', $avatar_url);
			$display->add('blast',$blast);
			$display->add('user_id',User::id());
				
			$TopMenu = $display->output('TopMenu',true,'Personal');
			$display->add('TopMenu',$TopMenu);
			
			$display->output('change_pass',false,'Personal');
		}
		else{
			Url::redirect('home');
		}
	}	
}
?>
